home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / comms / other / dwarfx-tng / dwarfx / dwarffriends.amirx < prev    next >
Text File  |  1999-04-19  |  8KB  |  54 lines

  1. /* DWaRFx Friends script V0.4 By David 'COolWAve' Newton
  2. \\
  3. // This script is used to automatically add/delete/edit to the !FRIENDS
  4. \\ section of the DWaRFx Config file.
  5. //
  6. \\ Usage: DWaRFFrIEnDS.AmIRX <ADD/SHOW/DEL> <friend> [settings]
  7. //
  8. \\   ADD - Adds (or updates) a friend. SHOW - Displays a friend.
  9. //   DEL - Deletes a friend.
  10. \\
  11. //  Where <friend> must be one of the following:
  12. \\
  13. //   [NICK] - This can only be used if [NICK] is on irc at the time!
  14. \\          - If this is used, DWaRFx will try and automatically use
  15. //          - wildcards when it thinks it's nessecary. If this doesn't seem
  16. \\          - to work, or it greets the wrong person, try the next option!
  17. //
  18. \\   [NICK!NAME@HOSTNAME] - The whole address of the friend to add. You
  19. //                        - can use '*' wildcards, and this is exactly
  20. \\                        - how DWaRFx will store it, so please make
  21. //                        - sure you understand how these work! If in doubt,
  22. \\                        - Use the [NICK] option :).
  23. //
  24. \\  Where [settings] can be none, one or more of the following:
  25. //
  26. \\   RATING <00-99> - Sets the status level of the friend (default is 00).
  27. //   OP - Sets Auto Op for this friend.
  28. \\   MESSAGE <[X][Y]> <[message]> - Greeting for this friend.
  29. //    IF MESSAGE IS USED, MESSAGE MUST ALWAYS BE THE LAST [settings] OPTION!
  30. \\    [X] must be either C or P, for Channel or Private greeting.
  31. //    [Y] must be either M, A or N, for Message, Action or Notice greeting.
  32. \\    The following '/'s commands are used by DWaRFx to make your messages
  33. //    better, as they allow you to make 'clever' messages (See Docs for
  34. \\    More Info). 
  35. //    Here is a quick list of the '/' options:
  36. \\
  37. //     If you require a / in the output text, you must use //
  38. \\     /p will be replaced with the nick of the person who CTCP'd you
  39. //     /n will be replaced with your current irc nickname
  40. \\     /s (<soundname>) will do a ctcp sound at their end
  41. //     /b /i /u turns Bold, Inverse and Underlined text On and Off
  42. \\     /t will be replaced with the current date and local time
  43. //     /v will be replaced with the DWaRFx version string
  44. \\     /w will be replaced with the DWaRFx Web Page address
  45. //     /l will be replaced with the DWaRFx logo
  46. \\     /c will be replaced by the current channel name
  47. //     /e will end the current line and start a new one
  48. \\     /d will be replaced with the DWaRFx Idle time string
  49. //
  50. \\ So the command line 'ADD COolWAve RATING 50 OP MESSAGE CN Hello Dave!'
  51. // Will add the current host using the nickname 'COolWAve' with a
  52. \\ RATING of 50, Auto Op on, and set the greeting to 'Hello Dave!'.  
  53. */
  54. ;Options Results;Parse Arg opt friend sets;dfxlogo=d2c(27)'x«DwFriends»';quote="'";message="";rating='00';op="";Parse Source . . drawer .;tmp=Pos('/',drawer);If tmp=0 Then tmp=Pos(':',drawer);Else tmp=Lastpos('/',drawer);drawer=Left(drawer,tmp);evnum=Substr(Address(),Pos('.',Address()));Call SetClip('DFxTIME'evnum,Time());Do While sets~="";Parse Value sets With tmp sets;tmp=Upper(tmp);Select;When tmp="RATING" Then Parse Value sets With rating sets;When tmp="OP" Then op="O";When tmp="MESSAGE" THEN;Do;op=op||"M";message=Strip(sets);sets="";mtmp=Upper(Left(Word(message,1),1));If mtmp~='P'&mtmp~='C' Then message="PN "message;End;Otherwise Call ERR(1);End;sets=Strip(sets);End;opt=Upper(opt);Select;When opt="ADD" Then Call ADD_FRIEND;When opt="DEL" Then Call DEL_FRIEND;When opt="SHOW" Then Call SHOW_FRIEND;Otherwise Call ERR(5);End;Exit;DEL_FRIEND:;Call GET_HOST();Call MATCH_HOST();If hostnum>1 Then;Do;'Echo P='dfxlogo' 'd2c(2)'DEL:'d2c(2)' More than one host matched with 'd2c(2)||host||d2c(2)'!';'Echo P='dfxlogo' 'd2c(2)'DEL:'d2c(2)' You must be more specific for the correct friend to be deleted!';End;Else;Do;If hostnum=0 Then 'Echo P='dfxlogo' 'd2c(2)'DEL:'d2c(2)' No friend match with the host 'd2c(2)||host||d2c(2)'!';Else;Do;'Echo P='dfxlogo' 'd2c(2)'DEL:'d2c(2)' Deleting old friend 'd2c(2)||Word(hosts.1,1)||d2c(2)'!';Call ALTER_CONF(1);'GetMyNick';'RAW PRIVMSG 'result' :%RELOAD QUIET';End;End;Return;ADD_FRIEND:;Call GET_HOST();Call MATCH_HOST();If hostnum>1 Then;Do;'Echo P='dfxlogo' 'd2c(2)'ADD:'d2c(2)' More than one host matched with 'd2c(2)||host||d2c(2)'!';'Echo P='dfxlogo' 'd2c(2)'ADD:'d2c(2)' You must be more specific for the correct friend to be added or updated!';End;Else;Do;If hostnum=0 Then;Do;'Echo P='dfxlogo' 'd2c(2)'ADD:'d2c(2)' Adding new friend 'd2c(2)||host||d2c(2)'!';Call ALTER_CONF(3);'GetMyNick';'RAW PRIVMSG 'result' :%RELOAD QUIET';End;Else;Do;'Echo P='dfxlogo' 'd2c(2)'ADD:'d2c(2)' Updating old friend 'd2c(2)||Word(hosts.1,1)||d2c(2)'!';Call ALTER_CONF(2);'GetMyNick';'RAW PRIVMSG 'result' :%RELOAD QUIET';End;End;Return;SHOW_FRIEND:;Call GET_HOST();Call MATCH_HOST();If hostnum>0 Then;Do;If hostnum=1 Then tmp='friend';Else tmp='friends';'Echo P='dfxlogo' 'd2c(2)'SHOW:'d2c(2)' 'hostnum' 'tmp' matched with the host 'd2c(2)||host||d2c(2)'.';End;Else 'Echo P='dfxlogo' 'd2c(2)'SHOW:'d2c(2)' No friend matched with the host 'd2c(2)||host||d2c(2)'!';Return;ERR:;Parse Arg errno;dfxerr='P='dfxlogo' 'd2c(2)'ERROR:'d2c(2);Select;When errno=1 Then 'Echo 'dfxerr' incorrect settings!';When errno=2 Then 'Echo 'dfxerr' no friend specified!';When errno=3 Then 'Echo 'dfxerr' 'friend' isn'quote't currently on IRC!';When errno=4 Then 'Echo 'dfxerr' DWaRFx config file (DWaRFCoNFiG.DaT) not found!';When errno=5 Then 'Echo 'dfxerr' no command found, you must use ADD or SHOW or DEL!';Otherwise;End;Exit;Return;GET_HOST:;If friend="" Then Call ERR(2);If Pos('@',friend)=0 Then;Do;'RAW WHOIS 'friend;host="";Do while host="";GetLine;If line="" Then Leave;If line.command="311" Then;Do;If Upper(Word(line.rest,1))=Upper(friend) Then host=Word(line.rest,1)'!'Word(line.rest,2)'@'Word(line.rest,3);End;If line.command="318" Then Leave;End;If host="" Then Call ERR(3);Parse Value host With junk'!'name'@'ip;If Datatype(Compress(ip,'.'))='NUM' Then host='*!'name'@'ip;Else host='*!'name'@'Space(Translate(ip,'          ','1234567890'),1,'*');End;Else host=friend;Return;MATCH_HOST:;If ~Open('file1',drawer||'DWaRFCoNFiG.DaT') Then Call ERR(4);scan=0;done="";hosts.1="";hostnum=0;Do While ~Eof('file1')&scan~=2;ln=Readln('file1');If scan=0 Then;Do;If Upper(Word(ln,1))="!FRIENDS:" Then scan=1;End;Else;Do;If Left(Word(ln,1),1)="!" Then scan=2;tmp=Upper(Word(ln,1))'.';nhost=Upper(host)'.';If ln~="" Then;Do;tmp1=Translate(nhost,' ','*');tmp2=1;Do loop1=1 To Words(tmp1);tmp2=Pos(Word(tmp1,loop1),tmp,tmp2);If tmp2=0 Then Leave;End;If tmp2=0 Then;Do;tmp1=Translate(tmp,' ','*');tmp2=1;Do loop1=1 To Words(tmp1);tmp2=Pos(Word(tmp1,loop1),nhost,tmp2);If tmp2=0 Then Leave;End;End;If tmp2~=0 Then;Do;tmp=Upper(Word(ln,3));If Left(tmp,1)="O" Then tmp1=" "d2c(2)"OP"d2c(2);Else tmp1="";If Right(tmp,1)="M" Then tmp2=" "d2c(2)"MESSAGE:"d2c(2)" ("d2c(2)||Upper(Word(ln,4))||d2c(2)") "Subword(ln,5);Else tmp2="";'Echo P='dfxlogo' 'd2c(2)||opt':'d2c(2)' 'Word(ln,1)' 'd2c(2)'RATING:'d2c(2)' 'Word(ln,2)||tmp1||tmp2;hostnum=hostnum+1;hosts.hostnum=ln;End;End;End;End;Call Close('file1');Return;ALTER_CONF:;Parse Arg altnum;tmph=Upper(Word(hosts.1,1));If ~Open('file1',drawer||'DWaRFCoNFiG.DaT') Then Call ERR(4);lines=1;line.1="";fr=0;Do While ~Eof('file1');line.lines=Readln('file1');If Upper(Word(line.lines,1))="!FRIENDS:" Then fr=1;If fr=1 Then;Do;Select;When altnum=1 Then Call DEL_LINE();When altnum=2 Then Call CHG_LINE();When altnum=3 Then Call ADD_LINE();End;End;lines=lines+1;End;Call Close('file1');If ~Open('file1',drawer||'DWaRFCoNFiG.DaT','W') Then Call ERR(4);loop=1;lines=lines-1;Do While loop<lines;Call Writeln('file1',line.loop);loop=loop+1;End;Call Close('file1');Return;ADD_LINE:;lines=lines+1;line.lines=host' 'rating' 'op' 'message;fr=0;Return;DEL_LINE:;If Upper(Word(line.lines,1))=tmph Then;Do;lines=lines-1;fr=0;End;Return;CHG_LINE:;If Upper(Word(line.lines,1))=tmph Then;Do;line.lines=host' 'rating' 'op' 'message;fr=0;End;Return